package guoan.domain;

import guoan.core.jodaJson.DateTimeYYYYMMDDSerializer;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

import org.hibernate.annotations.Type;
import org.joda.time.DateTime;
import org.springframework.format.annotation.DateTimeFormat;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;

/**
 * 预约陪练报名
 * 
 */
@Embeddable
public class CoachItemCheckPK implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 * 开放时间
	 */
	@Column(name = "open_hours")
	private String openHours;

	/**
	 * 考试ID
	 */
	@Column(name = "coach_id")
	private Long coachId;

	/**
	 * 考试时间
	 */
	@Column(name = "exam_time")
	@DateTimeFormat(pattern = "yyyy-MM-dd")
	@JsonSerialize(using = DateTimeYYYYMMDDSerializer.class)
	@Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
	private DateTime examTime;

	@Column(name = "train_id")
	private Long trainId;

	public CoachItemCheckPK() {
		super();
	}

	public CoachItemCheckPK(String openHours, Long coachId, DateTime examTime, Long trainId) {
		super();
		this.openHours = openHours;
		this.coachId = coachId;
		this.examTime = examTime;
		this.trainId = trainId;
	}

	public String getOpenHours() {
		return openHours;
	}

	public void setOpenHours(String openHours) {
		this.openHours = openHours;
	}

	public Long getCoachId() {
		return this.coachId;
	}

	public void setCoachId(Long examId) {
		this.coachId = examId;
	}

	public DateTime getExamTime() {
		return this.examTime;
	}

	public void setExamTime(DateTime examTime) {
		this.examTime = examTime;
	}

	public Long getTrainId() {
		return trainId;
	}

	public void setTrainId(Long trainId) {
		this.trainId = trainId;
	}

	public boolean equals(Object other) {
		if (this == other) {
			return true;
		}
		if (!(other instanceof CoachItemCheckPK)) {
			return false;
		}
		CoachItemCheckPK castOther = (CoachItemCheckPK) other;
		return this.trainId.equals(castOther.trainId) && this.openHours.equals(castOther.openHours)
				&& this.examTime.equals(castOther.examTime) && this.coachId.equals(castOther.coachId);
	}

	public int hashCode() {
		final int prime = 31;
		int hash = 17;
		hash = hash * prime + this.trainId.hashCode();
		hash = hash * prime + this.openHours.hashCode();
		hash = hash * prime + this.examTime.hashCode();
		hash = hash * prime + this.coachId.hashCode();

		return hash;
	}

}